<!--
 * @Author: gaofang
 * @Date: 2020-11-03 09:16:59
 * @LastEditTime: 2021-08-04 11:45:34
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
-->
<template>
  <a-card>
    <div style="margin-top: 10px" :bordered="false">
      <a-tabs default-active-key="1" @change="callback" class="nav_active">
        <!-- 加载的组件  -->
        <!-- 待办任务 tab -->
        <a-tab-pane key="1" tab="待办任务">
          <waitTask
            :FlowName="FlowName"
            ref="waitingTask"
            @send-record="checkHandle"
          ></waitTask>
        </a-tab-pane>

        <!-- 已办任务 tab -->
        <a-tab-pane key="2" tab="已办任务">
          <!-- 已办任务 组件 -->
          <finishTask
            :FlowName="FlowName"
            ref="finishingTask"
            @send-record="finishCheck"
          ></finishTask>
        </a-tab-pane>
      </a-tabs>

      <a-modal v-model="dialogVisible" width="70%">
        <!-- Modal 页脚按钮 -->
        <template slot="footer">
          <!-- 所有的按钮 -->
          <modalBar
            :duty_name="duty_name"
            :tabKey="tabKey"
            :nextTaskarray="nextTaskarray"
            :assigneeArray="ASSIGNEE_array"
            :nextStepType="next_step_type"
            @send-task="sendTask"
            @close-modal="closeModal"
            @end-task="endTask"
          ></modalBar>
        </template>

        <!-- Modal 对话框内容 -->
        <div id="printTest">
          <a-divider>其它出库申请反馈</a-divider>

          <a-descriptions
            title
            bordered
            :column="{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 1, xs: 1 }"
            style="text-align: right"
          >
            <a-descriptions-item label="申请单号">
              <div style="text-align: left">
                <span style="border: 0">{{ form.requisitionNo }}</span>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="申请日期">
              <div style="text-align: left">
                <span style="border: 0">{{ form.applicationDate }}</span>
              </div>
            </a-descriptions-item>
            <!-- <a-descriptions-item label="所属单位" :span="1">
              <div style="text-align:left">
                <span style="border:0">{{ form.subordinate_text }}</span>
              </div>
            </a-descriptions-item> -->
            <!-- <a-descriptions-item label="仓库名称" :span="1">
              <div style="text-align:left">
                <span style="border:0">{{ form.applicationDepot_text }}</span>
              </div>
            </a-descriptions-item> -->
            <a-descriptions-item label="申请部门">
              <div style="text-align: left">
                <span style="border: 0">{{ form.draftDepartment_text }}</span>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="申请人">
              <div style="text-align: left">
                <span style="border: 0">{{ form.applicant_text }}</span>
              </div>
            </a-descriptions-item>

            <!-- <a-descriptions-item label="收发类别" :span="1">
              <div style="text-align:left">
                <span style="border:0;text-align:left">{{
                  form.sendReceiveType_text
                }}</span>
              </div>
            </a-descriptions-item> -->
            <a-descriptions-item label="用途" :span="2">
              <div style="text-align: left">
                <span style="border: 0; text-align: left">{{
                  form.remarks
                }}</span>
              </div>
            </a-descriptions-item>
            <!-- <a-descriptions-item></a-descriptions-item> -->
          </a-descriptions>

          <a-divider>其它出库申请列表</a-divider>

          <a-table
            :columns="columns"
            :dataSource="dataSource"
            :pagination="true"
            bordered
          >
            <span
              slot="actualQuantity"
              slot-scope="text, record"
              label="实发数量"
            >
              <a-input-number
                v-if="ShiFaShuLiang"
                v-model="record.actualQuantity"
                :min="0"
                :precision="3"
              />
              <span v-if="!ShiFaShuLiang">{{ record.actualQuantity }}</span>
            </span>
          </a-table>

          <!--  动态生成工作流填入意见  -->
          <a-divider>流程审批意见</a-divider>

          <!--  动态生成工作流填入意见  -->
          <a-descriptions
            bordered
            :column="{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 1, xs: 1 }"
            style="text-align: right"
          >
            <a-descriptions-item
              v-for="(item, index) in workForm"
              :key="index"
              :label="item.label"
              :span="3"
              style="width: 200px"
            >
              <div>
                <a-textarea
                  v-model="item.desc"
                  :disabled="
                    duty_name == workflow_Array[index] && tabKey == 1
                      ? false
                      : true
                  "
                  style="background-color: white; color: black; width: 100%"
                  :auto-size="{ minRows: 2 }"
                />
              </div>
              <div style="margin-top: 10px; text-align: left">
                <a-row>
                  <a-col :span="9">
                    <a-radio-group
                      v-model="item.radio_value"
                      @change="radio_Change(index)"
                    >
                      <a-radio
                        style="margin-left: 5px"
                        :value="1"
                        :disabled="
                          duty_name == workflow_Array[index] && tabKey == 1
                            ? false
                            : true
                        "
                      >
                        同意
                      </a-radio>
                      <a-radio
                        :value="2"
                        :disabled="
                          duty_name == workflow_Array[index] && tabKey == 1
                            ? false
                            : true
                        "
                      >
                        不同意
                      </a-radio>
                    </a-radio-group>
                  </a-col>
                  <a-col :span="9">
                    签名：
                    <img
                      v-if="!item.signImg"
                      :src="item.sign"
                      style="width: 100px; height: 30px"
                    />
                    <span v-if="item.signImg">{{ item.sign }}</span>
                  </a-col>
                  <a-col :span="6">日期：{{ item.date }}</a-col>
                </a-row>
              </div>
            </a-descriptions-item>
          </a-descriptions>
          <!-- <workflow
            :duty_name="duty_name"
            @submit-assignee="Submit"
            @reset-form="resetForm"
            ref="workflow"
          ></workflow> -->
        </div>
      </a-modal>
    </div>
  </a-card>
</template>

<script>
// 加载 工作流变动接口
import { workflowHttp } from "../../services/modules/workFlow";
const wfHttp = new workflowHttp();

// import workflow from "@/components/common/workFlow";

// 已办任务组件
import waitTask from "../../components/common/waitTask";

// 已办任务组件
import finishTask from "../../components/common/finishTask";

// 按钮组件
import modalBar from "../../components/common/modalBar";
const columns = [
  {
    title: "序号",
    dataIndex: "key",
    key: "key",
    align: "center",
  },
  // {
  //   title: "所属单位",
  //   key: "subordinate_text",
  //   dataIndex: "subordinate_text",
  //   align: "center",
  //   // scopedSlots: { customRender: "subordinate_text" },
  // },
  {
    //! 这里传编码
    title: "仓库编码",
    key: "applicationDepotCode_text",
    dataIndex: "applicationDepotCode_text",
    align: "center",
    // scopedSlots: { customRender: "applicationDepotCode_text" },
  },
  {
    //! 传name
    title: "仓库名称",
    key: "applicationDepot_text",
    dataIndex: "applicationDepot_text",
    align: "center",
  },
  {
    title: "存货编码",
    dataIndex: "inventoryNo",
    key: "inventoryNo",
    align: "center",
    // scopedSlots: { customRender: "inventoryNo" },
  },
  {
    title: "存货名称",
    dataIndex: "inventoryNane",
    key: "inventoryNane",
    align: "center",
  },
  {
    title: "规格型号",
    dataIndex: "standardModel",
    key: "standardModel",
    align: "center",
  },
  {
    title: "单位",
    key: "unit",
    dataIndex: "unit",
    align: "center",
  },
  {
    title: "申请数量",
    dataIndex: "applyNumber",
    key: "applyNumber",
    align: "center",
    // scopedSlots: { customRender: "applyNumber" },
  },
  {
    title: "实发数量",
    dataIndex: "actualQuantity",
    key: "actualQuantity",
    align: "center",
    scopedSlots: { customRender: "actualQuantity" },
  },
];

export default {
  components: {
    waitTask,
    finishTask,
    modalBar,
    // workflow,
  },
  data() {
    return {
      // ------------ 工作流传递参数 ----------------

      // 详情-上半部分
      form: {
        requisitionNo: "", //申请单号
        applicationDate: "", //申请日期
        // subordinate_text: "", //所属单位
        applicationDepot_text: "", //仓库名称
        draftDepartment_text: "", //申请部门
        applicant_text: "", //申请人
        // sendReceiveType_text: "", //收发类别
        projectsUnderConstruction: "", //在建项目
      },
      columns,
      dataSource: [],
      ShiFaShuLiang: false, //实发数量插槽

      applicantName: "", // 申请人姓名
      applicantDate: "", //  申请人日期

      workForm: [],
      Label: ["部门负责人意见", "仓库管理员意见"],
      peoplehitaskList: "", //存储目前审批人到哪一步

      ASSIGNEE_: "", // 要提交的办理人

      // ------ 工作流产生数据 ------------
      checkData: [], //采购物品信息表格数据

      tabKey: 1, // 全局 tab Key

      dialogVisible: false, // 办理 modal 显示
      infoVisible: false, // 详情 modal 显示
      finishInfoVisible: false, // 已办任务详情 modal 展示

      nextTask: "", // 下一级任务节点名称

      array: [], // 办理人信息数组
      array2: [], // 工作流程数组

      // ------ 工作流通用数据
      FlowName: "其他出库流程", // 流程名称
      duty_name: "", // 当前任务进程名称
      workflow_Array: [], // 工作流数组，记录了当前工作流的所有流程步骤
      storeId: "", // 存储 任务ID ，待办任务中，提交按钮 需要提交任务ID
      TableItemID_: [], //已办-表格-一条数据的id

      // ------ 传递到 modalBar 组件的数据
      nextTaskarray: [], // 下一级任务节点数组
      next_step_type: "", // 用来控制下一步任务是单选还是多选,下一步任务办理人是单选还是多选
      ASSIGNEE_array: [], // 下一步办理人数组
      PROC_INST_ID_: "",

      ASSIGNEE_Key: [], // 办理人key值,包含所有的唯一的key值
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.postUpcomingTasksList(); //代办任务列表

    this.getDutyInfo();
  },
  methods: {
    // 传递过去任务名称，获取流程数组
    sendDutyName() {
      this.$refs.workflow.getProcessName();
    },
    // ---------- 工作流方法 ----------

    // tab 标签页 的回调函数
    callback(key) {
      if (key === "1") {
        // 待办任务列表
        this.tabKey = 1;
        // 刷新代办任务列表
        this.checkData = [];
        this.refreshCheckTask();
      } else if (key === "2") {
        // 已办任务列表
        this.tabKey = 2;
        this.finishData = [];
        // this.refreshFinishTask();
        // 刷新已办任务列表
      }
    },
    //  提交函数
    Submit(queryPath) {
      console.log("拼接好的下一步办理人数据", queryPath);
    },
    // 表单重置
    resetForm() {
      console.log("表单重置");
    },
    // ---------------- 获取待办任务列表 -------------------
    postUpcomingTasksList() {
      (res) => {
        if (res.success === true) {
          let renderData = res.result.varList;
          this.data = renderData.map((item, index) => {
            item.key = index;
            return item;
          });
        }
      };
    },
    // 根据当前流程渲染表单,用来控制工作流程中哪一部分可以填写
    getDutyInfo() {
      // this.FlowName
      let query_name = "?name=" + this.FlowName;
      console.log("查询路径", query_name);
      wfHttp.getProcessstepByFlowName(query_name).then((res) => {
        console.log("工作流程步骤信息:::", res);
        this.workflow_Array = [];
        this.workflow_Array.push(res.result.firstTask);
        let array = res.result.processStep.split(",");
        for (let i = 0; i < array.length; i++) {
          this.workflow_Array.push(array[i]);
        }
        this.workForm = [];
        // 根据返回的工作流程,动态生成流程表单
        for (let i = 0; i < this.workflow_Array.length; i++) {
          let data = {
            desc: "", // 描述框
            signImg: "true",
            sign: "",
            date: "",
            label: this.Label[i], // 标签
            radio_value: "",
            // this.workForm()
          };
          this.workForm.push(data);
        }
        console.log("工作流程步骤表单:::", this.workflow_Array);
        console.log("工作流程步骤信息:::", this.workForm);
      });
    },
    //------------- 电子签名处理函数 -------------------

    getSignImg(data) {
      let signImg = "";
      if (data == null || data == "") {
        signImg = true;
      } else {
        signImg = false;
      }
      return signImg;
    },

    // 根据 电子签名显示标识 来控制如何显示,sign 是渲染的签名，
    // signImg 签名如何显示控制器，sign_name 申请人姓名，sign_Img申请人电子签名
    showSignImg(signImg, sign_name, sign_Img) {
      var sign = "";
      if (signImg == true) {
        sign = sign_name;
      } else {
        sign = sign_Img;
      }
      return sign;
    },
    // 单选按钮触发事件
    radio_Change(index) {
      console.log(this.workForm[index]);
      if (this.workForm[index].radio_value == 1) {
        this.workForm[index].desc = "同意";
      } else {
        this.workForm[index].desc = "不同意";
      }
    },
    // -------------- tab 1 待办任务 ----------------------
    // 重新刷新待办任务列表
    refreshCheckTask() {
      this.$refs.waitingTask.postTasksList();
    },

    // 待办任务组件触发函数, 点击办理按钮触发
    checkHandle(record) {
      this.ShiFaShuLiang = false;
      console.log("record", record);
      console.log("record.TASK_DEF_KEY_", record.TASK_DEF_KEY_);
      if (record.TASK_DEF_KEY_ == "OtheroutUT3") {
        //"仓库管理员审批"
        this.ShiFaShuLiang = true; //实发数量审批插槽
      } else {
        this.ShiFaShuLiang = false; //实发数量审批插槽
      }
      console.log("插槽输出值this.ShiFaShuLiang", this.ShiFaShuLiang);

      this.getDutyInfo();
      this.ASSIGNEE_Key = [];
      console.log("显示时哪个任务+++++++++++++", this.tabKey);
      // console.log("待办任务列表中的一条数据+++++++++++++", record);

      // 工作流表单清空,重新构造

      let PROC_INST_ID_ = record.PROC_INST_ID_; // 实例流程ID
      this.storeId = record.ID_;
      let FILENAME = record.DGRM_RESOURCE_NAME_;
      console.log("文件名称:::::", FILENAME);
      let singleFormData = new FormData();

      singleFormData.append("PROC_INST_ID_", PROC_INST_ID_);
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("FILENAME", FILENAME);

      // 待办任务
      wfHttp.postProcessInformation(singleFormData).then((res) => {
        console.log("res返回的总体工作流数据+++++++++++", res);
        let lengthTemp = res.result.hitaskList.length - 1;
        this.peoplehitaskList = res.result.hitaskList[lengthTemp].ACT_ID_; //记录当前的进行到的审批位置
        console.log(
          "！！！！！！！！！！！！this.peoplehitaskList",
          this.peoplehitaskList
        );

        this.duty_name = res.result.currentTask; // 获取当前的任务
        console.log("当前任务名称:::", this.duty_name);

        this.nextTaskarray = []; // 重置下一步任务列表
        this.ASSIGNEE_array = []; // 重置下一步办理人列表

        // 控制下拉选择框是单选还是多选
        if (res.result.nextUserNameList.length == 1) {
          this.next_step_type = "default";
        } else {
          this.next_step_type = "multiple";
        }

        // 解析下一步任务数组、解析下一步人员数组
        for (let i = 0; i < res.result.nextUserNameList.length; i++) {
          this.nextTaskarray.push(res.result.nextUserNameList[i].taskName); // 下一步任务数组

          // 下一步人员信息
          let keysArray = Object.keys(
            res.result.nextUserNameList[i].userNameAndId
          );
          console.log("获取所有用户id:::::", keysArray);

          for (let j = 0; j < keysArray.length; j++) {
            // 包含 key 值
            console.log(keysArray[j]);
            console.log(this.ASSIGNEE_Key.indexOf(keysArray[j]) == -1);

            if (this.ASSIGNEE_Key.indexOf(keysArray[j]) == -1) {
              let data = {
                userId: keysArray[j],
                userName:
                  res.result.nextUserNameList[i].userNameAndId[keysArray[j]],
              };
              console.log("用户数据::::", data);
              this.ASSIGNEE_array.push(data);
              this.ASSIGNEE_Key.push(keysArray[j]);
            }
          }
        }
        console.log("下一步任务数组:::", this.nextTaskarray);
        console.log("下一步人员信息:::", this.ASSIGNEE_array);

        let varList = res.result.varList; // 申请人提交的数据
        let hitaskList = res.result.hitaskList; // 工作流产生数据
        console.log("申请人提交数据:::", varList);
        console.log("工作流产生数据:::", hitaskList);

        // --------- 申请人数据 ---------------
        this.form = {
          requisitionNo: varList[0].TEXT_, // 申请单号
          applicationDate: varList[4].TEXT_, // 申请日期
          subordinate_text: varList[2].TEXT_, //! 所属单位
          applicationDepot_text: varList[1].TEXT_, // 仓库名称
          draftDepartment_text: varList[2].TEXT_, // 申请部门
          applicant_text: varList[3].TEXT_, // 申请人
          // sendReceiveType_text: varList[5].TEXT_, //! 收发类别,没有返回
          remarks: varList[6].TEXT_, //用途
        };
        this.applicantName = hitaskList[1].ASSIGNEE_;
        this.applicantDate = hitaskList[1].START_TIME_;

        //数据列表
        this.dataSource = [];
        for (let i = 7, k = 1; i < varList.length; i++, k++) {
          this.TableItemID_[k - 1] = varList[i].ID_; //表格中一条数据id
          console.log(
            "this.TableItemID_[i] = varList[i].ID_;",
            this.TableItemID_[i]
          );
          let array = [];
          array = varList[i].TEXT_.split(";");
          // console.log(array);
          let data = {
            key: k, //序号
            id: array[0], //id
            subordinate_text: array[1], //所属单位
            applicationDepotCode_text: array[2], //仓库编码
            applicationDepot_text: array[3], //仓库名称
            inventoryNo: array[4], //存货编码
            inventoryNane: array[5], //存货名称
            standardModel: array[6], //规格型号
            unit: array[7], //单位
            applyNumber: array[8], //申请数量
            actualQuantity: array[9], //实发数量
          };
          if (data.applyNumber === null || data.applyNumber === "null") {
            data.applyNumber = "";
          }
          if (data.actualQuantity === null || data.actualQuantity === "null") {
            data.actualQuantity = "";
          }
          if (data.standardModel === null || data.standardModel === "null") {
            data.standardModel = "";
          }
          if (data.unit === null || data.unit === "null") {
            data.unit = "";
          }
          this.dataSource.push(data);
        }

        // --------- 工作流数据 ---------------
        // 利用for 循环来渲染数据,渲染的数据是目前已经完成的任务

        for (let j = 0; j < hitaskList.length; j++) {
          for (let i = 0; i < this.workflow_Array.length; i++) {
            if (hitaskList[j].ACT_NAME_ == this.workflow_Array[i]) {
              console.log(hitaskList[j].ACT_NAME_);
              if (hitaskList[j].END_TIME_ != null) {
                this.workForm[i].desc = hitaskList[j].TEXT_; // 下一个描述
                this.workForm[i].date = hitaskList[j].END_TIME_.substring(
                  0,
                  10
                );
                this.workForm[i].signImg = this.getSignImg(hitaskList[j].eUrl);
                this.workForm[i].sign = this.showSignImg(
                  this.workForm[i].signImg,
                  hitaskList[j].ASSIGNEE_,
                  hitaskList[j].eUrl
                );
              }
            }
          }
        }

        this.dialogVisible = true;
      });
    },

    // 给办理提交函数提供接口，并返回信息
    do_submit(data) {
      this.workflow_Array.forEach((item, index) => {
        if (this.duty_name == item && this.workForm[index].desc !== "") {
          wfHttp.postHandleTasks(data).then((res) => {
            if (res && res.code === 200) {
              this.$message.success("发送成功");
              // 刷新待办任务列表
              this.checkData = [];
              this.dialogVisible = false;
              this.refreshCheckTask();
            } else {
              this.$message.error("发送失败");
            }
          });
        }
        if (this.duty_name == item && this.workForm[index].desc == "") {
          this.$message.error("请选择意见");
        }
      });
    },
    // 办理结束
    do_end(data) {
      wfHttp.postHandleTasks(data).then((res) => {
        if (res && res.code === 200) {
          this.$message.success("结束成功");
          this.closeModal(); // 结束父组件对话框
          this.refreshCheckTask(); // 待办列表刷新
          // 刷新待办任务列表
        } else {
          this.$message.error("结束失败");
        }
      });
    },

    //  发送按钮触发函数
    sendTask(data) {
      console.log("选择好的下一步办理人数据::::", data);
      this.dataTemp = data;
      let singleFormData = data;
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("msg", "yes");

      //判断走流程还是走修改
      if (this.peoplehitaskList == "OtheroutUT3") {
        let controlIsNotBreak = this.updateSendTask(this.dataTemp);
        console.log("发送按钮中的controlIsNotBreak", controlIsNotBreak);
        if (!controlIsNotBreak) {
          console.log("进入return，中断");
          return;
        }
      } else {
        // 一次提交一条记录
        for (let i = 0; i < this.workflow_Array.length; i++) {
          if (this.duty_name == this.workflow_Array[i]) {
            singleFormData.append("OPINION", this.workForm[i].desc);
            break;
          }
        }
        console.log("要提交的数据:::::", singleFormData);
        this.do_submit(singleFormData); // 提交
      }

      this.ShiFaShuLiang = false; //实发数量插槽
    },
    //判断实发数量是否填写
    judgeShiFaShuLiang() {
      let temp = 1;
      if (this.ShiFaShuLiang == true) {
        this.dataSource.forEach((element) => {
          if (
            element.actualQuantity === "" ||
            element.actualQuantity === null
          ) {
            temp = "";
          }
        });
        return temp;
      } else {
        return temp;
      }
    },
    //! 修改接口
    updateSendTask(data) {
      console.log("data", data);
      console.log("表格中的信息", this.dataSource);
      let controlIsNotBreak = true;
      let judgeTemp = this.judgeShiFaShuLiang();
      console.log("judgeTemp", judgeTemp);
      if (judgeTemp == "" || null) {
        controlIsNotBreak = false;
        this.$message.error("请填写实发数量！");
        return controlIsNotBreak;
      } else {
        console.log("进入else");
        console.log("选择好的下一步办理人数据::::", data);
        let singleFormData = data;
        singleFormData.append("ID_", this.storeId);
        singleFormData.append("msg", "yes");
        console.log("this.storeId", this.storeId);
        // let id_ = this.storeId;
        //purchaseGoodsEntity和text_都需要传,因为修改的地方有两处
        let warehouseoutside = [];
        let text_ = "";
        console.log("this.dataSource", this.dataSource);

        for (let i = 0; i < this.dataSource.length; i++) {
          let warehouseInside = {};

          let id_ = this.TableItemID_[i];
          console.log("this.TableItemID_", this.TableItemID_);
          console.log("this.TableItemID_[i]", this.TableItemID_[i]);

          // console.log("采购id!!!!!!!!!!!!", this.purchaserList);
          let warehouseOtherOutboundContentEntity = {
            id: this.dataSource[i].id,
            actualQuantity: Number(this.dataSource[i].actualQuantity), //实发数量
          };
          text_ =
            this.dataSource[i].id +
            ";" +
            this.dataSource[i].subordinate_text + //所属单位,目前没有用到
            ";" +
            this.dataSource[i].applicationDepotCode_text + //仓库编码
            ";" +
            this.dataSource[i].applicationDepot_text + //仓库名称
            ";" +
            this.dataSource[i].inventoryNo + //存货编码
            ";" +
            this.dataSource[i].inventoryNane + //存货名称
            ";" +
            this.dataSource[i].standardModel + //规格型号
            ";" +
            this.dataSource[i].unit + //单位
            ";" +
            this.dataSource[i].applyNumber + //申请数量
            ";" +
            this.dataSource[i].actualQuantity; //实发数量

          warehouseInside.id_ = id_;
          warehouseInside.warehouseOtherOutboundContentEntity =
            warehouseOtherOutboundContentEntity;
          warehouseInside.text_ = text_;
          warehouseoutside.push(warehouseInside);

          console.log("warehouseInside", warehouseInside); // text_.push(data);
          console.log("warehouseoutside", warehouseoutside); // text_.push(data);
        }

        console.log("进行到此处22222222222222222222！！！");

        let queryPath = "?processName=" + "其他出库流程";
        console.log("processName", queryPath);

        console.log("这是最终修改接口穿的对象", warehouseoutside);
        wfHttp.updatechangeForm(queryPath, warehouseoutside).then((res) => {
          console.log(res);
          if (res && res.code === 200) {
            for (let i = 0; i < this.workflow_Array.length; i++) {
              if (this.duty_name == this.workflow_Array[i]) {
                console.log("当前工作流的申请意见", this.workForm[i].desc);
                singleFormData.append("OPINION", this.workForm[i].desc);
                break;
              }
            }
            console.log("要提交的数据:::::", singleFormData);
            this.do_submit(singleFormData); // 提交
          } else {
            this.$message.error("操作失败");
          }
        });
        controlIsNotBreak = true;
        return controlIsNotBreak;
      }
    },
    // 结束按钮
    endTask() {
      let singleFormData = new FormData();
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("msg", "no");
      // 一次提交一条记录
      for (let i = 0; i < this.workflow_Array.length; i++) {
        if (this.duty_name == this.workflow_Array[i]) {
          singleFormData.append("OPINION", this.workForm[i].desc);
          break;
        }
      }
      console.log("要提交的数据:::::", singleFormData);
      this.do_end(singleFormData);
    },
    // -------------- tab 2 已办任务 ----------------------
    // 重新刷新已办任务列表
    refreshFinishTask() {
      console.log("已办任务", this.$refs);
      this.$refs.finishingTask.finishTaskList();
    },

    // 已办任务组件触发函数，点击详情触发
    finishCheck(record) {
      this.ShiFaShuLiang = false; //实发数量审批插槽
      this.getDutyInfo();
      let PROC_INST_ID_ = record.PROC_INST_ID_; // 实例流程ID
      let FILENAME = record.DGRM_RESOURCE_NAME_;
      console.log("文件名称:::::", FILENAME);
      let singleFormData = new FormData();
      singleFormData.append("PROC_INST_ID_", PROC_INST_ID_);
      singleFormData.append("FILENAME", FILENAME);

      wfHttp.postQueryHisInfo(singleFormData).then((res) => {
        if (res && res.code === 200) {
          console.log("已办任务列表+++++++++++", res);

          let varList = res.result.varList; // 申请人提交的数据
          let hitaskList = res.result.hitaskList; // 工作流产生数据
          console.log("申请人提交数据:::", varList);
          console.log("工作流产生数据:::", hitaskList);

          // --------- 申请人数据 ---------------
          this.form = {
            requisitionNo: varList[0].TEXT_, // 申请单号
            applicationDate: varList[4].TEXT_, // 申请日期
            subordinate_text: varList[2].TEXT_, //! 所属单位
            applicationDepot_text: varList[1].TEXT_, // 仓库名称
            draftDepartment_text: varList[2].TEXT_, // 申请部门
            applicant_text: varList[3].TEXT_, // 申请人
            // sendReceiveType_text: varList[5].TEXT_, //! 收发类别,没有返回
            remarks: varList[6].TEXT_, //用途
          };
          this.applicantName = hitaskList[1].ASSIGNEE_;
          this.applicantDate = hitaskList[1].START_TIME_;
          this.dataSource = [];
          for (let i = 7, k = 1; i < varList.length; i++, k++) {
            let array = [];
            array = varList[i].TEXT_.split(";");
            // console.log(array);
            let data = {
              key: k, //序号
              id: array[0],
              subordinate_text: array[1], //所属单位
              applicationDepotCode_text: array[2], //仓库编码
              applicationDepot_text: array[3], //仓库名称
              inventoryNo: array[4], //存货编码
              inventoryNane: array[5], //存货名称
              standardModel: array[6], //规格型号
              unit: array[7], //单位
              applyNumber: array[8], //申请数量
              actualQuantity: array[9], //实发数量
            };
            if (data.applyNumber === null || data.applyNumber === "null") {
              data.applyNumber = "";
            }
            if (
              data.actualQuantity === null ||
              data.actualQuantity === "null"
            ) {
              data.actualQuantity = "";
            }
            if (data.unit === null || data.unit === "null") {
              data.unit = "";
            }
            if (data.standardModel === null || data.standardModel === "null") {
              data.standardModel = "";
            }
            this.dataSource.push(data);
          }

          // --------- 工作流数据 ---------------
          // 利用for 循环来渲染数据,渲染的数据是目前已经完成的任务

          for (let j = 0; j < hitaskList.length; j++) {
            for (let i = 0; i < this.workflow_Array.length; i++) {
              if (hitaskList[j].ACT_NAME_ == this.workflow_Array[i]) {
                console.log(hitaskList[j].ACT_NAME_);
                if (hitaskList[j].END_TIME_ != null) {
                  this.workForm[i].desc = hitaskList[j].TEXT_; // 下一个描述
                  this.workForm[i].date = hitaskList[j].END_TIME_.substring(
                    0,
                    10
                  );
                  this.workForm[i].signImg = this.getSignImg(
                    hitaskList[j].eUrl
                  );
                  this.workForm[i].sign = this.showSignImg(
                    this.workForm[i].signImg,
                    hitaskList[j].ASSIGNEE_,
                    hitaskList[j].eUrl
                  );
                }
              }
            }
          }

          this.dialogVisible = true;
        } else {
          this.$message.error("服务器异常");
        }
      });
    },

    //  父组件对话框结束
    closeModal() {
      this.dialogVisible = false;
    },
  },
};
</script>

<style lang="less" scoped>
.list-content-item {
  color: rgba(0, 0, 0, 0.45);
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
  span {
    line-height: 20px;
  }
  p {
    margin: 4px 0 0;
    line-height: 22px;
  }
}
textarea {
  border: 0;
  border-radius: 5px;
  background-color: rgba(241, 241, 241, 0.98);
  width: 100%;
  height: 100px;
  padding: 10px;
  resize: none;
}
.tablehah {
  margin-top: 15px;
}
</style>
